package com.tczs.server.request;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public abstract class AbstractGetMethodBuildParameter extends AbstractBuildParameter{

    @Override
    public Map<String, Object> build(Object obj){
        if(Objects.isNull(obj))
            return null;
        String params = (String)obj;
        String[] paramArray = params.split("&");
        Map<String, Object> parameterMap = new HashMap<>();
        for (String param : paramArray) {
            String[] paramArray2 = param.split("=");
            parameterMap.put(paramArray2[0], paramArray2[1]);
        }
        return parameterMap;
    }


    @Override
    public  Map<String, Object> buildParameter(Object str){
        String o = (String) beforeBuild(str);
        Map<String, Object> build = build(o);
        Map<String, Object> stringObjectMap = afterBuild(build);
        return  stringObjectMap;
    }
}
